<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>个人考勤</title>
    <link rel="stylesheet" href="../../../layui/css/layui.css">
    <script src="../../../layui/layui.js"></script>
</head>
<style type="text/css">
    body{
        height: 100%;
        width: 100%;
        margin-top: 11px;
    }


</style>

<body >
<!-- 内容主体区域 -->
<div class="layui-fluid layui-form">
    <div class="layui-form-item">
        <div class="layui-input-inline " style=" width: 638px;">
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width:70px">选择门店</label>
            <div class="layui-input-inline" id="qq">
                <select id="type" name="salon">
                    <option value="chidao">迟到</option>
                    <option value="zaotui">早退</option>
                    <option value="queqin">缺勤</option>
                    <option value="0571">请假</option>
                    <!--<option value="0571">杭州</option>-->
                </select>
            </div>
            <div class="layui-input-inline" id="date">
                <select id="time" name="salon">
                    <option value="01">一月</option>
                    <option value="02">二月</option>
                    <option value="03">三月</option>
                    <option value="04">四月</option>
                    <option value="05">五月</option>
                    <option value="06">六月</option>
                    <option value="07">七月</option>
                    <option value="08">八月</option>
                    <option value="09">九月</option>
                    <option value="10">十月</option>
                    <option value="11">十一月</option>
                    <option value="12">十二月</option>
                </select>
            </div>
           <!-- <label class="layui-form-label">选择时间</label>
            <div class="layui-inline"> &lt;!&ndash; 注意：这一层元素并不是必须的 &ndash;&gt;
                <input type="text" class="layui-input" id="test1">
            </div>
-->
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button class="layui-btn layuiadmin-btn-admin layui-btn-normal check" lay-submit="" lay-filter="LAY-user-back-search">
                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                </button></div>
        </div>
        <div class="layui-inline">
<!--            <div class="layui-input-inline">
                <input type="text" name="userKey" class="layui-input userKeyValue ">
            </div>-->
<!--            <div class="layui-input-inline" style="width: 38px;">
                <button class="layui-btn layuiadmin-btn-admin layui-btn-normal check" lay-submit="" lay-filter="LAY-user-back-search">
                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                </button>

            </div>-->
<!--            <div class="layui-input-inline" style="width: 179px;">
            <label class="layui-form-label">应出勤数：</label>
            <div class="layui-inline"> &lt;!&ndash; 注意：这一层元素并不是必须的 &ndash;&gt;
                <input type="text" class="layui-input attendanceNum" style="width: 58px;"/>
            </div>
            </div>
            <div class="layui-input-inline" style="width: 179px;">
            <label class="layui-form-label">共出勤数：</label>
            <div class="layui-inline"> &lt;!&ndash; 注意：这一层元素并不是必须的 &ndash;&gt;
                <input type="text" class="layui-input hasAttendanceNum" style="width: 58px;"/>
            </div>
            </div>
            <div class="layui-input-inline" style="width: 179px;">
            <label class="layui-form-label">异常数：</label>
            <div class="layui-inline"> &lt;!&ndash; 注意：这一层元素并不是必须的 &ndash;&gt;
                <input type="text" class="layui-input yichangNum" style="width: 58px;"/>
            </div>
            </div>-->
            <!--<button class='layui-btn'>详情</button>-->
        </div>
    </div>
</div>
<input type="hidden" id="stuffId"/>
<div id="pTable" >
    <table id="layui_table_id" class="layui-table" lay-skin="line" lay-filter="test" style="width: 1680px">

    </table>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-xs" lay-event="edit">查看</a>
        </script>
    <div id="laypage"></div>
</div>
</body>
</html>

<script type="text/javascript">

    function child(data) {
        var $ = layui.jquery;
        var stuffId = data.stuffId;
        $('#stuffId').val(stuffId);
        productsearch(1, "", stuffId, "2019-03","chidao");

    }
    layui.use(['form','laydate','layer','table','laypage','util','jquery'],function() {
        var $ = layui.jquery;
        $(".check").on("click", function() {
            var stuffId = $("#stuffId").val();
            var date=new Date;
            var year=date.getFullYear();
            var userKey=$('#time option:selected').val();

            var type=$('#type option:selected').val();

            var tmep  ="";
            if(userKey!=""){
                tmep = year+"-"+userKey;
            }else{
                tmep = year+"-"+date.getDay();
            }
            if(type!=""){

            }else{
                type="";
            }
            productsearch(1,"123",stuffId,tmep,type);
        })
    })
    function productsearch(page,filterExpr,stuffId,time,type) {
                layui.use(['form','laydate','layer','table','laypage','util','jquery'],function(){
                var table = layui.table;
                    laydate = layui.laydate;
                var $ = layui.jquery;
                var form = layui.form;
                table.render({
                    elem : '#layui_table_id',
                    url : '/hy/basic/timeSheet/getRYTimeSheetTypeTimeStuffId',
                    cols : [ [
                        {checkbox: true,
                            filter:'test'
                        }
                        , {
                            field : 'day',
                            title : '日期',
                            align : 'center'
                        }
                        , {
                            field : 'timeStart',
                            title : '上班打卡时间',
                            align : 'center'
                        }
                        , {
                            field : 'timeEnd',
                            title : '下班打卡时间',
                            align : 'center'
                        }, {
                            field : 'type',
                            title : '考勤状态',
                            align : 'center'
                        }
                    ] ],
                    page : true,
                    where : {
                        stuffId:stuffId,
                        time:time,
                        filterExpr:filterExpr,
                        type:type
                    },
                    responseHandler: function (res, curr,count) {
                        $('#pageNum').val(curr);
                        $(".attendanceNum").val(res.attendanceNum);
                        $(".hasAttendanceNum").val(res.hasAttendanceNum);
                        $(".yichangNum").val(res.yichangNum);
                        return {
                            "count": res.total,
                            "data": res.data,
                            "code": 0,//code值为200表示成功
                            "msg": ""
                        }
                    },
                    done : function(res, curr, count) {
                        console.log(res)
                        $('#pageNum').val(curr);

                    }
                })
                init();
                function init() {
                    $.ajax({
                        type:'get',
                        url:'/hy/basic/timeSheet/getSalon',
                        data:{page:1,limit:20},
                        success: function(data){
                            var dataList =data.data;
                            var html="<option value=''>请选择门店</option>";
                            for(var i=0;i<dataList.length;i++){
                                html+="<option value='"+dataList[i].recordId+"'>"+dataList[i].salonName+"</option>";
                            }
                            $("#salon").append(html);
                            form.render('select');
                        },
                        error:function(data){
                            alert("操作失败");
                            console.log(data);
                        }
                    })
                }
                // table.on('checkbox(test)', function(obj){
                //   console.log(layui.table.checkStatus('layui_table_id'));
                // });
                // 监听工具条
                table.on('tool(test)', function(obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                    var data = obj.data, //获得当前行数据
                        layEvent = obj.event; //获得 lay-event 对应的值
                    if (layEvent == 'detail') {
                        queryById(data.id);
                    } else if (layEvent == 'del') {
                        //alert(data.id)
                        var pageNum = $('#pageNum').val();
                        layer.confirm('真的删除行么', function(index){
                            layer.close(index);
                        });
                    } else if (layEvent === 'edit') {
                        timeSeetingItem(data);
                    }
                });
                //常规用法
                laydate.render({
                    elem : '#initialStoreId'
                });
                //常规用法
                laydate.render({
                    elem : '#processingTime'
                });


                    //搜索

                });
            }
</script>
